//===================================================================================
// $$
//
// Coder: Code Milker v1.0
// 0 - EntityName
// 1 - Properties
//===================================================================================


namespace App.Domain.Handlers {
    using System;
    using App.Data;
    using App.Domain.Contracts;
    using App.Domain.Models;

    public class CreateSkill {
        private readonly ISkillRepository _skillRepository;

        public CreateSkill(ISkillRepository skillRepository) {
            _skillRepository = skillRepository;
        }

        public void Execute(Guid userId, ICreateSkillCommand skillForm) {
            if (skillForm == null)
                throw new ArgumentNullException("skillForm");

            try {
                var skill = skillForm.ConvertToEntity();
                _skillRepository.Create(skill);
            }
            catch (InvalidOperationException ex) {
                throw new BusinessServicesException("UnableToCreateVehicleExceptionMessage", ex);
            }
        }
    }
}
